/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: XMQ
 * Date: 2022-05-31
 * Time: 17:10
 */
//自定义异常
class UserException extends RuntimeException{
    public UserException() {
    }

    public UserException(String message) {
        super(message);
    }
}
class PasswordException extends RuntimeException{
    public PasswordException() {
    }

    public PasswordException(String message) {
        super(message);
    }
}
public class TestDemo2 {
    public static final String admin = "Admin";
    public static final String password = "123456";

    public static void loginInfo(String a, String b){
        if(a.equals(admin)){
            throw new UserException();
        }
        if(b.equals(password)){
            throw new PasswordException();
        }
        System.out.println("登录成功");
    }
    public static void main(String[] args) {
        try{
            loginInfo("Admin","123");
        }catch (UserException e){
            System.out.println("用户名错误："+ admin);
        }catch (PasswordException e){
            System.out.println("密码错误："+ password);
        }
    }
}
